package com.cy.study.controller;

import com.cy.study.common.Response;
import com.cy.study.entity.MajorEntity;
import com.cy.study.service.MajorService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 专业控制器
 */
@RestController
@RequiredArgsConstructor
@Slf4j
@RequestMapping("/major")
@CrossOrigin
public class MajorController {

    private final MajorService majorService;

    /**
     * 获取所有专业
     * @return
     */
    @GetMapping("/getMajor")
    public Response<List<MajorEntity>> getMajor(){
        List<MajorEntity> majors = majorService.getMajor();
        return Response.success(majors);
    }

}
